package demo.node;


/**
 * @author : feixiang.li
 * @since : 2025-09-19 13:45
 */
public class Solution_140 {
    public ListNode trainingPlan(ListNode head, int cnt) {
        ListNode cur = head;
        ListNode pre = head;
        int i = 1;
        while (cur.next != null) {
            i++;
            cur = cur.next;
        }

        // cur 是尾结点
        // 一共 i 个节点 ，pre 只需要跑 i - cnt 个节点
        for(int j = 0; j < i - cnt; j++){
            pre = pre.next;
        }
        return pre.next;
    }


    public static void main(String[] args) {

    }
}
